<template>
  <div class="app">
    <el-table :data="holdPostData" style="width: 100%">
      <el-table-column label="起止时间" width="200" align="center">
        <template slot-scope="scope">
          {{scope.row.startTime + (scope.row.endTime === null?' ~ 至今':scope.row.endTime)}}
        </template>
      </el-table-column>
      <el-table-column prop="postChangeTypeId" label="变动类型" width="120" align="center"></el-table-column>
      <el-table-column prop="organizationName" label="所属组织机构" align="center"></el-table-column>
      <el-table-column prop="postTypeName" label="岗位类型" width="180" align="center"></el-table-column>
      <el-table-column prop="postName" label="岗位名称" width="200" align="center"></el-table-column>
      <el-table-column prop="organizationCode" label="描述" align="center"></el-table-column>
    </el-table>
    <el-pagination
      @current-change="handleCurrentChange"
      :current-page="queryParams.current"
      layout="total, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
import {getHoldPostPageList} from '@/api/employee/employee/employee.js';
export default {
  name: "HoldPost",
  dicts: [],
  components: { },
  props:{
    prop:{
      type:Object,
      default:function(){
        return {employeeId:null,employeeCode:null}
      }
    }
  },
  data() {
    return {
      queryParams:{
        current:1,
        size:10,
        employeeId:this.prop.employeeId,
      },
      total:0,
      holdPostData:[],
    };
  },
  methods: {
    getPageList(){
      getHoldPostPageList(this.queryParams).then(res =>{
        let data = res.data
        this.holdPostData = data.records;
        this.holdPostData.forEach(hpd =>{
          switch (hpd.postChangeTypeId){
            case '0':
              hpd.postChangeTypeId = '入职'
              break;
            case '1':
              hpd.postChangeTypeId = '调岗'
              break;
            default:
              hpd.postChangeTypeId = '入职'
              break;
          }
        })
        this.total = data.total
      }).catch(err =>{
        console.log('查询职级分页数据失败，原因：',err)
      })
    },
    // 翻页
    handleCurrentChange(val) {
      this.current = val;
      this.getEmployeeInfoMethod();
    },
  },
  mounted() {
    this.getPageList()
  }

};
</script>
<style scoped>

</style>
